﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Erebos.ScreenFiles
{
    class MessageBox
    {
        private string _text;
        private bool _canClose;
        private bool _isClosed;

        public MessageBox(string text, bool canClose = false)
        {
            _text = text;
            _canClose = canClose;
        }

        public void Update()
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Space) && _canClose)
                _isClosed = true;
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            if (!_isClosed)
            {
                Vector2 pos = new Vector2((int)(ScreenSizeHelper.SizeWidth / 2 - MainGame.Textures["Box"].Width / 2), (int)(ScreenSizeHelper.SizeHeight / 2 - MainGame.Textures["Box"].Height / 2));
                spriteBatch.Draw(MainGame.Textures["Box"], pos, Color.White);
                Vector2 textSize = MainGame.Fonts["Arial10"].MeasureString(_text);
                Vector2 pos2 = pos + new Vector2((int)(MainGame.Textures["Box"].Width / 2 - textSize.X / 2), (int)(MainGame.Textures["Box"].Height / 2 - textSize.Y / 2));
                spriteBatch.DrawString(MainGame.Fonts["Arial10"], _text, pos2, Color.White);
            }
        }
    }
}
